<template>
	<view>
		<view class="imgClass">
			<img :src="infoFerm.img" alt="">
		</view>
		<view class="titleText">
			<view class="titleText_1">{{ infoFerm.price }}</view>
			<view class="titleText_2">{{ infoFerm.title }}</view>
			<view class="titleText_2">兑换规则：{{ infoFerm.consu }}</view>
		</view>
		<u-button text="兑换" @click="addIntegral(infoFerm.price)" type="primary"></u-button>
	</view>
</template>

<script>
import { subtractScore } from "@/api/index.js";
export default {
	data() {
		return {
			infoFerm:{}
		};
	},
	onLoad(e) {
		console.log(JSON.parse(decodeURIComponent(e.info)));
		this.infoFerm = JSON.parse(decodeURIComponent(e.info))
	},
	methods: {
		addIntegral(e) {
			subtractScore({
				score: e
			}).then((res) => {
				if (res.code == 0) {
					uni.showToast({
						title: res.msg,
						icon: "none",
						duration: 2000,
					});
				} else {
					uni.showToast({
						title: res.msg,
						icon: "none",
						duration: 2000,
					});
				}
			})
		}
	},
}
</script>

<style lang="less">
.imgClass{
	width: 100%;
	height: 240px;
	img{
		width: 100%;
		height: 100%;
	}
}
.titleText{
	    margin-left: 15px;
    line-height: 43px;
	&_1{
		font-size: 32px;
		color: #e75e58;
	}
	&_2{

	}
}
</style>
